#include"Ring.h"

void Stack:: StackPush(int m)
{

    Stack* NewNode=(Stack*)malloc(sizeof(Stack));
    (*this)._next=NewNode;
     while(--m)
     {
         NewNode->_data=rand()%100;
         NewNode->_next=(Stack*)malloc(sizeof(Stack));
         NewNode=NewNode->_next;
     }
    NewNode->_data=4;
    NewNode->_next=(*this)._next;
}



Stack*Stack:: StackPop(int &m,int n)
{

    Stack *head=&(*this);
    Stack*tail=head->_next;
    Stack* prev=NULL;
   while(tail->_next!=tail)
   {
       int gap=n;
       while(gap--)
       {
           prev=tail;
           tail=tail->_next;
       }
       Stack* next=tail->_next;
       printf("%d ->",tail->_data);
       free(tail);
       prev->_next=next;
       tail=next;
   }
    (*this)._next=prev;
}